<?php /* D:\phpStudy\PHPTutorial\WWW\laravel-admin\resources\views/admin/order/overOrders.blade.php */ ?>
<style>
    /*背景层*/
    #popLayer {
        display: none;
        background-color: #B3B3B3;
        position: absolute;
        top: 0px;
        right: 0px;
        bottom: 0px;
        left: 0px;
        z-index: 10;
        -moz-opacity: 0.8;
        opacity:0.80;
        filter: alpha(opacity=80);/* 只支持IE6、7、8、9 */
    }

    /*弹出层*/
    #popBox {
        display: none;
        background-color: #FFFFFF;
        position:absolute;
        z-index: 110;
        width: 90%;
        height:90%;
        top:0;
        right:0;
        left:0;
        bottom:0;
        opacity:1;
        margin:auto;
    }
</style>

<div id="popLayer" ></div>
<div id="popBox"  >
    <span style="padding:10px;background: #787878;float:right;color:white" onclick="closeFrame()" >关闭</span>
    <iframe id="popFrame"  style="width:100%;height:100%;border:1px solid #bbb;"  src=""></iframe>
</div>
<div id="app">
    <section class="content-header">
        <h1>
            <small>已完成订单列表</small>
        </h1>
    </section>

    <section class="content">
        <div class="row">
            <div class="col-md-12">
                <div class="box">
                    <div class="box-header with-border">



                        <span>
   <input type="checkbox" class="grid-select-all" />&nbsp;

    <a class="btn btn-sm btn-primary grid-refresh" title="刷新"><i class="fa fa-refresh"></i><span class="hidden-xs"> 刷新</span></a>






<div class="btn-group" style="margin-right: 10px" data-toggle="buttons">
        <label id="setGroupId"   class="btn btn-sm btn-dropbox" title="分组">
             <span class="hidden-xs">分组</span>
        </label>
    </div>
    <div class="btn-group" style="margin-right: 10px" data-toggle="buttons">
        <label class="btn btn-sm btn-dropbox shaixuan-filter-btn" title="筛选">
            <input type="checkbox"><i class="fa fa-filter"></i><span class="hidden-xs">筛选</span>
        </label>
    </div>
  </span>

                    </div>

                    <!--   筛选开始   -->
                    <div class="box-header with-border hide" id="filter-box">
                        <form action="/admin/order/overOrders" class="form-horizontal" pjax-container method="get">
                            <div class="row">
                                <div class="col-md-12">
                                    <div class="box-body">
                                        <div class="fields-group">

                                            <div class="form-group">
                                                <label class="col-sm-2 control-label">订单来源</label>
                                                <div class="col-sm-8">
                                                    <select class="form-control order_comefrom" id="order_comefrom" name="order_comefrom" style="width: 100%;">
                                                        <option value="-1"></option>
                                                        <?php if($channel): ?>
                                                            <?php $__currentLoopData = $channel; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $k=>$v): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                                <option value="<?php echo e($k, false); ?>"><?php echo e($v, false); ?></option>
                                                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                                        <?php endif; ?>

                                                    </select>
                                                </div>
                                            </div>

                                            <div class="form-group">
                                                <label class="col-sm-2 control-label">订单类型</label>
                                                <div class="col-sm-8">
                                                    <select class="form-control order_type" id="order_type" name="order_type" style="width: 100%;">
                                                        <option value=""></option>
                                                        <option value="1">分期购买</option>
                                                        <option value="2">全款购买</option>
                                                    </select>
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <label class="col-sm-2 control-label">订单分组</label>
                                                <div class="col-sm-8">
                                                    <select class="form-control group_id" id="group_id" name="group_id" style="width: 100%;">
                                                        <option value=""></option>
                                                        <?php if($order_group): ?>
                                                            <?php $__currentLoopData = $order_group; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $k=>$v): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                                <option value="<?php echo e($k, false); ?>"><?php echo e($v, false); ?></option>
                                                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                                        <?php endif; ?>
                                                    </select>
                                                </div>
                                            </div>


                                            <div class="form-group">
                                                <label class="col-sm-2 control-label"> 订单号</label>
                                                <div class="col-sm-8">
                                                    <div class="input-group input-group-sm">
                                                        <div class="input-group-addon">
                                                            <i class="fa fa-pencil"></i>
                                                        </div>

                                                        <input type="text" class="form-control order_id" placeholder="订单号" name="order_id" value="<?php if(!empty($where['order_id'])): ?> <?php echo e($where['order_id'], false); ?> <?php endif; ?>">
                                                    </div>    </div>
                                            </div>

                                            <div class="form-group">
                                                <label class="col-sm-2 control-label"> 商品名称</label>
                                                <div class="col-sm-8">
                                                    <div class="input-group input-group-sm">
                                                        <div class="input-group-addon">
                                                            <i class="fa fa-pencil"></i>
                                                        </div>

                                                        <input type="text" class="form-control goods_name" placeholder="商品名称" name="goods_name" value="<?php if(!empty($where['goods_name'])): ?> <?php echo e($where['goods_name'], false); ?> <?php endif; ?>">
                                                    </div>    </div>
                                            </div>

                                            <div class="form-group">
                                                <label class="col-sm-2 control-label">手机号</label>
                                                <div class="col-sm-8">
                                                    <div class="input-group input-group-sm">
                                                        <div class="input-group-addon">
                                                            <i class="fa fa-pencil"></i>
                                                        </div>

                                                        <input type="text" class="form-control user_phone" placeholder="手机号" name="user_phone" value="<?php if(!empty($where['user_phone'])): ?> <?php echo e($where['user_phone'], false); ?> <?php endif; ?>">
                                                    </div>    </div>
                                            </div>

                                            <div class="form-group">
                                                <label class="col-sm-2 control-label">姓名</label>
                                                <div class="col-sm-8">
                                                    <div class="input-group input-group-sm">
                                                        <div class="input-group-addon">
                                                            <i class="fa fa-pencil"></i>
                                                        </div>

                                                        <input type="text" class="form-control user_name" placeholder="姓名" name="user_name" value="<?php if(!empty($where['user_name'])): ?> <?php echo e($where['user_name'], false); ?> <?php endif; ?>">
                                                    </div>    </div>
                                            </div>




                                            <div class="form-group">
                                                <label class="col-sm-2 control-label">下单时间</label>
                                                <div class="col-sm-8" style="width: 390px">
                                                    <div class="input-group input-group-sm">
                                                        <div class="input-group-addon">
                                                            <i class="fa fa-calendar"></i>
                                                        </div>
                                                        <input type="text" class="form-control" id="create_time_start"   name="start_time" value="<?php if(!empty($where['start_time'])): ?> <?php echo e($where['start_time'], false); ?> <?php endif; ?>">
                                                        <span class="input-group-addon" style="border-left: 0; border-right: 0;">-</span>
                                                        <input type="text" class="form-control" id="create_time_end"   name="end_time" value="<?php if(!empty($where['end_time'])): ?> <?php echo e($where['end_time'], false); ?> <?php endif; ?>">
                                                    </div>
                                                </div>
                                            </div>

                                        </div>
                                    </div>
                                </div>
                            </div>
                            <!-- /.box-body -->

                            <div class="box-footer">
                                <div class="row">
                                    <div class="col-md-12">
                                        <div class="col-md-2"></div>
                                        <div class="col-md-8">
                                            <div class="btn-group pull-left">
                                                <button class="btn btn-info submit btn-sm"><i
                                                            class="fa fa-search"></i>&nbsp;&nbsp;搜索</button>
                                            </div>
                                            <div class="btn-group pull-left " style="margin-left: 10px;">
                                                <a href="/admin/order/overOrders" class="btn btn-default btn-sm"><i
                                                            class="fa fa-undo"></i>&nbsp;&nbsp;重置</a>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </form>
                    </div>
                    <!--筛选结束-->

                    <!--  分组   -->
                    <div class="box-header with-border hide" id="group-box">
                        <form  id="groupForm" class="form-horizontal"  >
                            <div class="row">
                                <div class="col-md-12">
                                    <div class="box-body">
                                        <div class="fields-group">
                                            <div class="form-group">
                                                <label class="col-sm-2 control-label"> 订单分组:</label>
                                                <div class="col-sm-8">
                                                    <select class="form-control order_type"  id="set_group_id" style="width: 100%;">
                                                        <option value=""></option>
                                                        <?php if($order_group): ?>
                                                            <?php $__currentLoopData = $order_group; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $k=>$v): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                                <option value="<?php echo e($k, false); ?>"><?php echo e($v, false); ?></option>
                                                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>

                                                        <?php endif; ?>
                                                    </select>

                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>

                            <div class="box-footer">
                                <div class="row">
                                    <div class="col-md-12">
                                        <div class="col-md-2"></div>
                                        <div class="col-md-8">
                                            <div class="btn-group pull-left">
                                                <?php echo csrf_field(); ?>
                                                <button  onclick="setGroup()" type="button" class="btn btn-info   btn-sm"> 设置分组</button>
                                            </div>

                                            <div class="btn-group pull-right">
                                                <button  onclick="delSetGroup()" type="button" class="btn btn-info   btn-sm"> 解除分组</button>
                                            </div>

                                        </div>
                                    </div>
                                </div>
                            </div>
                        </form>
                    </div>
                    <!-- 分组结束 -->




                    <!-- /.box-header -->
                    <!--数据列表开始   -->
                    <div class="box-body table-responsive no-padding">
                        <table class="table table-hover"  >
                            <thead >
                            <tr >
                                <th> </th>
                                
                                <th> 订单状态</th>
                                <th>订单来源</th>
                                <th>所属分组</th>
                                <th>订单号</th>
                                <th>先享后付风控</th>

                                <th>商品名称</th>
                                <th>信用分</th>

                                <th>客户名称</th>
                                <th>客户手机号</th>
                                <th>收货地址</th>
                                <th>下单时间</th>
                                <th>总期数</th>
                                <th>剩余期数</th>
                                <th>剩余还款金额</th>
                                <th>第三方订单号</th>

                                <th>快递公司</th>
                                <th>快递单号</th>
                                <th>备注信息</th>
                                <th>操作</th>
                            </tr>
                            </thead>

                            <tbody>

                            <?php if(!empty($data['data'])): ?>
                                <?php $__currentLoopData = $data['data']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $v): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <tr >
                                        <td >
                                            <input type="checkbox" class="grid-row-checkbox" data-id="<?php echo e($v['order_id'], false); ?>" />
                                        </td>
                                        <td >
                                            <?php echo e($v['order_status'], false); ?>

                                        </td>
                                        <td >
                                            <?php echo e($v['order_comefrom'], false); ?>

                                        </td>
                                        <td >
                                            <?php if($v['group_name']): ?>
                                                <?php $__currentLoopData = $v['group_name']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $group_name): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                                    <?php echo e($group_name, false); ?><br />
                                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                            <?php endif; ?>
                                        </td>
                                        <td >
                                            <?php echo e($v['order_id'], false); ?>

                                        </td>
                                        <td >
                                            <?php echo e($v['log_xxhf'], false); ?>

                                        </td>
                                        <td >
                                            <?php echo e($v['goods_name'], false); ?>

                                        </td>

                                        <td >
                                            <?php echo e($v['zm_credit_score'], false); ?>

                                        </td>
                                        <td >
                                            <?php echo e($v['user_name'], false); ?>

                                        </td>
                                        <td >
                                            <?php echo e($v['user_phone'], false); ?>

                                        </td>
                                        <td >
                                            <?php echo e($v['order_address'], false); ?>

                                        </td>
                                        <td >
                                            <?php echo e($v['order_create_time'], false); ?>

                                        </td>
                                        <td >
                                            <?php echo e($v['order_tenancy_term'], false); ?>

                                        </td>
                                        <td >
                                            <?php echo e($v['order_repay_period'], false); ?>

                                        </td>
                                        <td >
                                            <?php echo e($v['order_rema_amount_pay'], false); ?>

                                        </td>
                                        <td >
                                            <?php echo e($v['zm_order_no'], false); ?>

                                        </td>

                                        <td >
                                            <?php echo e($v['express'], false); ?>

                                        </td>
                                        <td >
                                            <?php echo e($v['exp_number'], false); ?>

                                        </td>
                                        <td >
                                            <?php echo e($v['order_remarks'], false); ?>

                                        </td>

                                        <td >
                                            <a onclick="popShow(this)" href="javascript:;"   data-href="/admin/order/orderShow?order_id=<?php echo e($v['order_id'], false); ?>">查看</a>
                                            | <a onclick="popShow(this)" href="javascript:;"   data-href="/admin/order/orderStagesInfo?order_id=<?php echo e($v['order_id'], false); ?>">账单</a>
                                        </td>

                                    </tr>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            <?php endif; ?>
                            </tbody>
                        </table>
                    </div>
                    <!--数据列表结束-->



                    <!-- 分页开始    -->
                    <div class="box-footer clearfix">
                        <?php if($data['data']): ?>
                            从 <b><?php echo e($data['from'], false); ?></b> 到 <b><?php echo e($data['to'], false); ?></b> ，总共 <b><?php echo e($data['total'], false); ?></b> 条
                            <ul class="pagination pagination-sm no-margin pull-right">
                                <!-- Previous Page Link -->
                                <?php if($data['page_list']): ?>
                                    <li class="page-item <?php if($data['current_page']==1): ?> disabled <?php endif; ?> ">
                                        <?php if($data['current_page']>1): ?>
                                            <a class="page-link" data-href="<?php echo e($data['page_url'], false); ?>&page=<?php echo e($data['up_page'], false); ?>" rel="next">&laquo;</a>
                                        <?php else: ?>
                                            <span class="page-link">&laquo;</span>
                                        <?php endif; ?></li>
                                    <?php $__currentLoopData = $data['page_list']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $v): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                        <?php if($v=='...'): ?>
                                            <li class="page-item disabled"><span class="page-link"><?php echo e($v, false); ?></span></li>
                                        <?php endif; ?>
                                        <?php if($v==$data['current_page']): ?>
                                            <li class="page-item active"><span class="page-link"><?php echo e($v, false); ?></span></li>
                                        <?php elseif($v!='...'): ?>
                                            <li class="page-item"><a class="page-link" data-href="<?php echo e($data['page_url'], false); ?>&page=<?php echo e($v, false); ?>"><?php echo e($v, false); ?></a></li>
                                        <?php endif; ?>
                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                    <li class="page-item <?php if($data['current_page']==$data['last_page']): ?> disabled <?php endif; ?> ">
                                        <?php if($data['current_page']<$data['last_page']): ?>
                                            <a class="page-link" data-href="<?php echo e($data['page_url'], false); ?>&page=<?php echo e($data['next_page'], false); ?>" rel="next">&raquo;</a>
                                        <?php else: ?>
                                            <span class="page-link">&raquo;</span>
                                        <?php endif; ?></li>
                                <?php endif; ?>
                            </ul>

                            <label class="control-label pull-right" style="margin-right: 10px; font-weight: 100;">
                                <small>显示</small>&nbsp;
                                <select class="input-sm grid-per-pager" name="per-page">
                                    <option value="<?php echo e($data['page_url'], false); ?>&per_page=10" >10</option>
                                    <option value="<?php echo e($data['page_url'], false); ?>&per_page=20" selected>20</option>
                                    <option value="<?php echo e($data['page_url'], false); ?>&per_page=30" >30</option>
                                    <option value="<?php echo e($data['page_url'], false); ?>&per_page=50" >50</option>
                                    <option value="<?php echo e($data['page_url'], false); ?>&per_page=100" >100</option>
                                </select>
                                &nbsp;<small>条</small>
                            </label>
                        <?php else: ?>
                            <div style="text-align: center;margin:20px;">未查到数据</div>
                        <?php endif; ?>
                    </div>
                    <!-- 分页结束    -->

                    <!-- /.box-body -->
                </div>
            </div>
        </div>

    </section>
</div>

<script data-exec-on-popstate>

    //多选id数组
    var selectedRows = function () {
        var selected = [];
        $('.grid-row-checkbox:checked').each(function(){
            selected.push($(this).data('id'));
        });
        return selected;
    }
    $(function () {
        $("#order_type").val("<?php if(!empty($where['order_type'])): ?><?php echo e($where['order_type'], false); ?><?php endif; ?>");
        $("#order_comefrom").val("<?php if(!empty($where['order_comefrom'])): ?><?php echo e($where['order_comefrom'], false); ?><?php endif; ?>");
        $("#group_id").val("<?php if(!empty($where['group_id'])): ?><?php echo e($where['group_id'], false); ?><?php endif; ?>");
        //日历插件
        $('#create_time_start').datetimepicker({"format":"YYYY-MM-DD HH:mm:ss","locale":"zh-CN"});
        $('#create_time_end').datetimepicker({"format":"YYYY-MM-DD HH:mm:ss","locale":"zh-CN","useCurrent":false});
        $("#create_time_start").on("dp.change", function (e) {
            $('#create_time_end').data("DateTimePicker").minDate(e.date);
        });
        $("#create_time_end").on("dp.change", function (e) {
            $('#create_time_start').data("DateTimePicker").maxDate(e.date);
        });





        //tr选中样式控制
        $('.grid-row-checkbox').iCheck({checkboxClass:'icheckbox_minimal-blue'}).on('ifChanged', function () {
            if (this.checked) {
                $(this).closest('tr').css('background-color', '#ffffd5');
            } else {
                $(this).closest('tr').css('background-color', '');
            }
        });



        $('.grid-select-all').iCheck({checkboxClass:'icheckbox_minimal-blue'});

        $('.grid-select-all').on('ifChanged', function(event) {
            if (this.checked) {
                $('.grid-row-checkbox').iCheck('check');
            } else {
                $('.grid-row-checkbox').iCheck('uncheck');
            }
        });





        //刷新
        $('.grid-refresh').on('click', function() {
            $.pjax.reload('#pjax-container');
            toastr.success('刷新成功 !');
        });

        //搜索
        $('.shaixuan-filter-btn').unbind('click');
        $('.shaixuan-filter-btn').click(function (e) {
            if ($('#filter-box').is(':visible')) {
                $('#filter-box').addClass('hide');
            } else {
                $('#filter-box').removeClass('hide');
            }
        });
        <?php if($where): ?>
        $('#filter-box').removeClass('hide');
        <?php endif; ?>

        //分组
        $('#setGroupId').unbind('click');
        $('#setGroupId').click(function (e) {
            if ($('#group-box').is(':visible')) {
                $('#group-box').addClass('hide');
            } else {
                $('#group-box').removeClass('hide');
            }
        });


        //改变分页量
        $('.grid-per-pager').on("change", function(e) {
            $.pjax({url: this.value, container: '#pjax-container'});
        });

        //分页
        $("a.page-link").click(function(e){
            var url=$(this).attr('data-href');
            $.pjax({url:url, container: '#pjax-container'});
        })
    });



    function xxhf() {
        var goods_ids=selectedRows().join();
        if(goods_ids=='' || goods_ids==null){
            swal('请选择商品', '', 'error'); return false;
        }
        if(Object.keys(zhuijia_id).length==0){
            swal('请选择渠道', '', 'error'); return false;
        }

        var ar=[];
        var i=0;
        $.each(zhuijia_id,function(k,v){
            ar[i]=v;i++;
        });
        var chastr=ar.join();
        console.log(chastr+'=='+goods_ids);
        $.ajax({
            url:"/admin/goods/shangjia",
            data:{goods_ids:goods_ids,chastr:chastr,_token:LA.token},
            type:'post',
            dataType:'json',
            success:function(m){
                if(m.status==1){
                    $.pjax.reload('#pjax-container');
                    toastr.success('上架成功');
                }else{
                    swal(m.message, '', 'error');
                }
            }
        });
    }

    //分组
    function setGroup() {
        if(selectedRows().length==0){
            swal('请选择订单', '', 'error'); return false;
        }
        var order_id=selectedRows();
        var group_id=$("#set_group_id").val();
        $.ajax({
            url:"/admin/order/setGroup",
            data:{order_id:order_id,_token:LA.token,group_id:group_id},
            type:'post',
            dataType:'json',
            success:function(m){
                if(m.status==1){
                    $.pjax.reload('#pjax-container');
                    toastr.success(m.message);
                }else{
                    swal(m.message, '', 'error');
                }
            }
        });
    }

    //解除分组
    function delSetGroup() {
        if(selectedRows().length==0){
            swal('请选择订单', '', 'error'); return false;
        }
        var order_id=selectedRows();
        var group_id=$("#set_group_id").val();
        $.ajax({
            url:"/admin/order/removeGroup",
            data:{order_id:order_id,_token:LA.token,group_id:group_id},
            type:'post',
            dataType:'json',
            success:function(m){
                if(m.status==1){
                    $.pjax.reload('#pjax-container');
                    toastr.success(m.message);
                }else{
                    swal(m.message, '', 'error');
                }
            }
        });
    }

    function popShow(e){
        var url=$(e).attr('data-href');
        $("#popLayer").show();
        $("#popBox").show();
        $("#popFrame").attr('src',url);
        console.log(url);
    }
    function closeFrame(e) {
        $("#popBox").css('display','none');
        $("#popFrame").attr('src','');
        $('#popLayer').css('display','none');
    }
</script>